// This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface 
// (the "Fluent UI") and is provided only as referential material to supplement the 
// Microsoft Foundation Classes Reference and related electronic documentation 
// included with the MFC C++ library software.  
// License terms to copy, use or distribute the Fluent UI are available separately.  
// To learn more about our Fluent UI licensing program, please visit 
// http://msdn.microsoft.com/officeui.
//
// Copyright (C) Microsoft Corporation
// All rights reserved.

// stdafx.cpp : source file that includes just the standard includes
// Manager.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

CManagerApp* afxGetApp()
{
	CWinApp* pWinApp = AfxGetApp();
	if(pWinApp && pWinApp->IsKindOf(RUNTIME_CLASS(CManagerApp)))
		return (CManagerApp*)pWinApp;
	return NULL;
}


CMainFrame* afxGetMainFrame()
{
	CWnd* pWnd = AfxGetMainWnd();
	if(pWnd && pWnd->IsKindOf(RUNTIME_CLASS(CMainFrame)))
		return (CMainFrame*)pWnd;
	return NULL;
}

CManagerDoc* afxGetActiveDocument(CFrameWnd* pFrame)
{
	CView* pView = afxGetActiveMainView(pFrame);
	if(pView)
	{
		CDocument* pDoc = pView->GetDocument();
		if(pDoc && pDoc->IsKindOf(RUNTIME_CLASS(CManagerDoc)))
			return (CManagerDoc*)pDoc;
	}
	return NULL;	
}

CManagerView* afxGetActiveMainView(CFrameWnd* pFrameWnd)
{
	CFrameWnd* pFrm = pFrameWnd;
	if(pFrameWnd == NULL)
		pFrm = afxGetMainFrame();
	if(pFrm)
	{
		CView* pView = pFrm->GetActiveView();
		if(pView)
		{
			
				return (CManagerView*)pView;
		}
	}
	return NULL;
}